package com.friend.chat.net

import com.friend.chat.page.bean.FriendBean
import com.friend.chat.page.bean.GroupBean
import com.friend.chat.page.bean.RoomBean
import com.friend.chat.page.bean.UserBean
import com.friend.chat.websocket.ChatMessageBean
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.*

/**
 * @des Api
 * @date 2021/9/24
 * @author gorilla
 */
interface IServer {
    @FormUrlEncoded
    @POST("/chat/chatUser/loginByPassword")
    suspend fun loginByPassword(@FieldMap map: HashMap<String, Any>): BaseResult<UserBean>

    @FormUrlEncoded
    @POST("/chat/chatUser/register")
    suspend fun register(@FieldMap map: HashMap<String, Any>): BaseResult<Boolean>

    @GET("/chat/chatFriend/getFriendsList")
    suspend fun getFriendsList(@Query("uid") userId: String): BaseResult<List<FriendBean>>

    @GET("/chat/group/getMyGroupList")
    suspend fun getMyGroupList(@Query("userId") userId: String): BaseResult<List<GroupBean>>

    @GET("/chat/chatFriend/getRoomList")
    suspend fun getRoomList(@Query("uid") userId: String): BaseResult<List<RoomBean>>

    @GET("/chat/chatFriend/getChatList")
    suspend fun getUnReadChatList(
        @Query("chatId") chatId: String,
        @Query("userId") userId: String
    ): BaseResult<List<ChatMessageBean>>

    @GET("/chat/chatFriend/getGroupChatList")
    suspend fun getUnReadGroupChatList(
        @Query("roomId") chatId: String,
        @Query("userId") userId: String
    ): BaseResult<List<ChatMessageBean>>




    @FormUrlEncoded
    @POST("/chat/chatFriend/addFriend")
    suspend fun addFriend(@Field("userId")  userId:String,@Field("friendId") friendId:String): BaseResult<Boolean>


    /**
     * 创建群
     */

    @POST("/chat/group/createGroup")
    suspend fun createGroup(@Body map: RequestBody): BaseResult<Boolean>

    @Multipart
    @POST("/chat/file/uploadHeader")
    suspend fun uploadHeader(
        @Part file: MultipartBody.Part
    ): BaseResult<String>
}
